

# 输出9*9乘法口诀表。
for x in range(1,10):
    for y in range(1,x+1):
        print(y," * ",x," = ",x * y,end=" ")
    print()


# 11. 求s=a+aa+aaa+aaaa+aa...a的值，其中a是一个数字。例如2+22+222+2222+22222(此时共有5个数相加)，几个数相加由键盘控制
"""
过程 ：
2 = 2 + 0
22 = 20 + 2
222 = 200 + 22
2222 = 2000 + 222
22222 = 20000 + 2222

n = 4
a = 2
temp = a * 10 ** n
"""
s = 0
a = 2
temp = 0

n = int(input("请输入一个整数:"))

for i in range(n):
     temp = a * 10 ** i + temp
     s += temp

# print(s)


sum = 0
a = 2
for x in range(1,4):
    temp = str(a) * x   # 字符串相乘的原理
    sum += int(temp)
print(sum)

# 2 * 1 = 2
# '2' * 2 = 22


# 12. 题目：打印出如下图案（菱形）:
x = 4
for n in range(1,x+1):
    star = "*" * (2*n-1)
    space = " " * (x-n)
    print(space + star)
for n in range(1,4):
    star = "*" * (7-2*n)
    space = " " * n
    print(space + star)


print("="*20)
# 第2种写法 ：center(width,fillchar)
x = 4
for n in range(1,x+1):
    star = "*" * (2*n-1)
    print(star.center(7))









